#!/usr/bin/env python2.5
import sys
import os
import os.path
from cogen.web import wsgi
from cogen.web.async import sync_input
from cogen.common import *
if not os.path.dirname(__file__) in sys.path[:1]:
    sys.path.insert(0, os.path.dirname(__file__))
   
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
m = Scheduler(default_priority=priority.LAST, default_timeout=15)
server = wsgi.WSGIServer(
           ('localhost', 9000),
            sync_input(application), #!!! load middleware for wsgi.input
            m,
            server_name='localhost')
m.add(server.serve)
try:
    m.run()
except (KeyboardInterrupt, SystemExit):
    pass
